package com.sugar.real.estate.module.business.controller.app.buildhouse;

import com.sugar.real.estate.framework.common.pojo.CommonResult;
import com.sugar.real.estate.module.business.controller.app.buildhouse.vo.AppBuildHouseDetailRespVO;
import com.sugar.real.estate.module.business.controller.app.buildhouse.vo.AppBuildHouseSimpleRespVO;
import com.sugar.real.estate.module.business.service.buildhouse.BuildHouseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;

import static com.sugar.real.estate.framework.common.pojo.CommonResult.success;

@Tag(name = "APP - 建房")
@RestController
@RequestMapping("/biz/build-house")
@Validated
public class AppBuildHouseController {

    @Resource
    private BuildHouseService buildHouseService;

    @GetMapping("/get")
    @Operation(summary = "获得建房")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PermitAll
    public CommonResult<AppBuildHouseDetailRespVO> getBuildHouse(@RequestParam("id") Long id) {
        return success(buildHouseService.appGetBuildHouse(id));
    }

    @GetMapping("/list")
    @Operation(summary = "获得所有建房信息")
    @PermitAll
    public CommonResult<List<AppBuildHouseSimpleRespVO>> getBuildHouseAll() {
        return success(buildHouseService.appGetBuildHouseAll());
    }
}